#include <bits/stdc++.h>

using namespace std;

class Solution {
public:
	vector<int> dailyTemperatures(vector<int>& temperatures) {
		vector<int> res(temperatures.size(), 0);
		stack<int> aux { { 0 } };
		for (int i = 1, len = temperatures.size(); i < len; i++) {
			while (!aux.empty() && temperatures[aux.top()] < temperatures[i]) {
				int idx = aux.top();
				res[idx] = i - idx; aux.pop();
			}
			aux.emplace(i);
		}

		return res;
	}

private:
};

int main()
{
	Solution solution;
	return 0;
}
